<?php
class sms
{
	static public function encode($value)
    {
        $p = 61;
        $str = '';  
        global $vcode;  
        while ($value >= $p)
        {
            $m = $value % $p;
            $str = $vcode[$m] . $str;
            $value = floor($value / $p);                    
        }
        if ($value > 0)
        {
            $str = $vcode[$value] . $str;
        }
        return $str;
    }
    
    
    static public function verifyEncode($id, $checkValue = 4208)
    {        
        $currentTime = time();
        $timeEncode = self::encode($currentTime);
        $value = $id + $checkValue;
        $valueEncode = self::encode($value);
        $result = $timeEncode . 'Z' . $valueEncode;
        return $result;  
    }
    
	static public function createWapUrl($id, $price,$type)
	{
		$verify = self::verifyEncode($id, 4208);
                if($type == 1){
                    $url = 'http://wap.sangtao.funring.vn/rt/get?id='.$id.'&v='.$verify.'&m='.$price.'&tg='.$verify;
                }else{
                    $url = 'http://wap.sangtao.funring.vn/rt/get?id='.$id.'&v='.$verify;
                }
		//sfContext::getInstance()->getLogger()->err($url);
        return $url;
	}
}

?>